import BinaryTree.BinaryTree;
import org.junit.Test;
import static org.junit.Assert.assertEquals;

public class tests {

    @Test
    public void testThatHeightIsZeroWhenTreeContainsOnlyRoot() throws Exception {
        BinaryTree binaryTree = new BinaryTree();
        binaryTree.addNode("A", "");
        Integer result = binaryTree.showHeight();
        assert (result == 0);
    }

    @Test
    public void testThatHeightIsOneWhenTreeContainsOneElement() throws Exception {
        BinaryTree binaryTree = new BinaryTree();
        binaryTree.addNode("A", "");
        binaryTree.addNode("B", "toLeft");
        Integer result = binaryTree.showHeight();
        assert (result == 1);
    }

    @Test
    public void testThatHeightIsTwoWhenTreeContainsCorrespondingNumberElements() throws Exception {
        BinaryTree binaryTree = new BinaryTree();
        binaryTree.addNode("A", "");
        binaryTree.addNode("B", "toLeft");
        binaryTree.addNode("C", "toRight");
        binaryTree.addNode("D", "toLeft");
        binaryTree.addNode("E", "toRight");
        Integer result = binaryTree.showHeight();
        assert (result == 2);
    }

    @Test
    public void testTreeToStringMethodWhenTreeNotContainsRoot() throws Exception {
        BinaryTree binaryTree = new BinaryTree();
        String result = binaryTree.toString();
        assertEquals("корень пустой", result);
    }

    @Test
    public void testTreeToStringMethodWhenTreeContainsOnlyRoot() throws Exception {
        BinaryTree binaryTree = new BinaryTree();
        binaryTree.addNode("A", "");
        String result = binaryTree.toString();
        assertEquals("корень - A; левый - левый элемент пустой; ; правый - правый элемент пустой; ", result);
    }

    @Test
    public void testTreeToStringMethodWhenTreeContainsOneElement() throws Exception {
        BinaryTree binaryTree = new BinaryTree();
        binaryTree.addNode("A", "");
        binaryTree.addNode("B", "toLeft");
        String result = binaryTree.toString();
        assertEquals("корень - A; левый - B; правый - правый элемент пустой; ", result);
    }


}
